import React, {Component} from "react";
import ReactDOM from "react-dom";
import { createStore } from "redux";

import App from "./App.js";

const reducer = (state = { count: 0 }, action) => {
  switch (action.type) {
    case "INCREASE":
      return { count: state.count + 1 };
    case "DECREASE":
      return { count: state.count - 1 };
    default:
      return state;
  }
};

const actions = {
  increase: () => ({type: 'INCREASE'}),
  decrease: () => ({type: 'DECREASE'})
}

const store = createStore(reducer);

store.subscribe(() =>
  console.log(store.getState())
);

class Todos extends Component {
  render(){
      return(
        <div>
          <div onClick={()=>store.dispatch(actions.increase()) }>INCREASE</div>
          <div onClick={()=>store.dispatch(actions.decrease()) }>DECREASE</div>
          </div>
      )
  }
}



ReactDOM.render(
  <React.StrictMode>
    <Todos />
  </React.StrictMode>,
  document.getElementById("root")
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
